/*
 * Copyright 2013-2015 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xdtech.hotel.monitor;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.xdtech.hotel.protocol.manager.DeviceMonitor;
import com.xdtech.hotel.protocol.manager.RoomMonitor;
import com.xdtech.hotel.util.RedisUtils;

/**
 * 
 * @author max.zheng
 * @create 2015-5-1下午4:43:45
 * @since 1.0
 * @see
 */
public class RoomMonitorClient extends Client {
	public RoomMonitorClient(String id)
	{
		super(id);
	}
	
	private List<RoomMonitorInfo> roomMonitorInfos =  Collections.synchronizedList(new ArrayList<RoomMonitorInfo>());

	public List<RoomMonitorInfo> getRoomMonitorInfos() {
		return roomMonitorInfos;
	}

	public void setRoomMonitorInfos(List<RoomMonitorInfo> roomMonitorInfos) {
		this.roomMonitorInfos = roomMonitorInfos;
	}

	public List<RoomMonitorInfo> clientGetRoomMonitorInfos()
	{
		List<RoomMonitorInfo> roomMonitorInfoToClientList = new ArrayList<RoomMonitorInfo>(this.roomMonitorInfos);
		setLastAccessedTime(System.currentTimeMillis());
		roomMonitorInfos.clear();
		return roomMonitorInfoToClientList;
	}
	/**
	 * 新创建的客户端，获取是所有的房间信息
	 * @author <a href="max.zheng@zkteco.com">郑志雄</>
	 * @since 2015-4-24 下午3:23:06
	 */
	public void loadAllRoomInfos()
	{
//		roomMonitorInfos.addAll(RedisUtils.getAllRoomInfos());
		roomMonitorInfos.addAll(RoomMonitor.monitorDatas.values());
	}
}
